package com.mbc.common.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.mbc.common.entities.SystemKey;

public class SystemKeyDAOImpls extends DAO<SystemKey> implements SystemKeyDAO {

	public SystemKeyDAOImpls(Connection conn)
	{
		this.conn = conn;
		this.table_name = "SystemKey";
	}

	@Override
	public long getKey() throws SQLException {
		long l_key = 0;
		query = "declare @key bigint; execute sp_ms_key_generate @param1=@key output; select @key";
		pstmt = conn.prepareStatement(query);
		rs = pstmt.executeQuery();
		if(rs.next())
			l_key = rs.getLong(1);
		rs.close();
		pstmt.close();
		return l_key;
	}

	@Override
	protected SystemKey readRecord(ResultSet rs) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}
	
	

}
